//
//  BaseViewController.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/2.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "BaseViewController.h"
//#import "XJMainTabBarViewController.h"
#import "XJChatMainViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController


#pragma mark - LifeCyle
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
   // [self.navigationController setNavigationBarHidden:NO animated:animated];
    
    [self setUpAcceptNote];
}

#pragma mark - 接受跟换控制
- (void)setUpAcceptNote
{
//    WEAKSELF
//    [[NSNotificationCenter defaultCenter]addObserverForName:LOGINSELECTCENTERINDEX object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
//        weakSelf.tabBarController.selectedIndex = DCTabBarControllerPerson; //跳转到我的界面
//    }];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
   // [self.navigationController setNavigationBarHidden:NO animated:animated];
}

#pragma mark - LifeCyle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = WHITE_COLOR;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    // 导航栏右侧按钮
    _navButtonRight = [UIButton buttonWithType:UIButtonTypeCustom];
    _navButtonRight.frame = CGRectMake(0, 0, 22, 22);
    [_navButtonRight setImage:[UIImage imageNamed:@"nav_message"] forState:UIControlStateNormal];
    [_navButtonRight addTarget:self action:@selector(navRightClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_navButtonRight];
    _navButtonRight.hidden = YES;
}

- (void)setNavTitle:(NSString *)navTitle{
    
    _navTitle = navTitle;
    self.navigationItem.title = navTitle;
}

//- (void)dealloc
//{
//    [[NSNotificationCenter defaultCenter] removeObserver:self];
//}

/**
 *  导航右按钮事件（默认无内容）
 */
- (void)navRightClick:(id)sender {
    XJLog(@"=> 消息 !");
    XJChatMainViewController * xjChatMainVC = [[XJChatMainViewController alloc]init];
    [self.navigationController pushViewController:xjChatMainVC animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
